package qj.ps;

import java.io.File;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class EclipseHandler {
	public static void main(String[] args) {
		ClasspathBuilder cb = new ClasspathBuilder();
		cb.addProjectDirs("bin",Arrays.asList(new File(AssemblerUI.projectHomeF.e() + "/working").listFiles()));
		cb.addLibRoot(AssemblerUI.projectHomeF.e()+ "/static/BUILD/lib");
		cb.addLibRoot(AssemblerUI.projectHomeF.e()+ "/prepare/vjars");
		cb.addLibRoot(AssemblerUI.projectHomeF.e()+ "/prepare/lib");
		
		cb.genClasspath(AssemblerUI.projectHomeF.e() + "/working/APPLICATION_centralconfig_CR_1978");
	}

	public static class ClasspathBuilder {
		List<ProjectDir> projectDirs = new LinkedList<ProjectDir>();
		LinkedList<String> libRoots = new LinkedList<String>();

		public void addProjectDirs(String classDir, List<File> projectDirs1) {
			for (File file : projectDirs1) {
				projectDirs.add(new ProjectDir(file, classDir));
			}
		}
		
		public void genClasspath(String projectPath) {
//			<?xml version="1.0" encoding="UTF-8"?>
//			<classpath>
//				<classpathentry kind="src" path="src"/>
//				<classpathentry kind="src" path="test"/>
//				<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

			System.out.println("" +
					"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
					"<classpath>\n" +
					"<classpathentry kind=\"src\" path=\"src\"/>\n" +
					"<classpathentry kind=\"con\" path=\"org.eclipse.jdt.junit.JUNIT_CONTAINER/4\"/>\n" +
					"<classpathentry kind=\"output\" path=\"bin\"/>\n" +
					"</classpath>");
		}

		public void addLibRoot(String libRoot) {
			libRoots.add(libRoot);
		}

		public static class ProjectDir {
			File dir;
			String classDir;
			public ProjectDir(File dir, String classDir) {
				this.dir = dir;
				this.classDir = classDir;
			}
		}
		
	}
}
